import { Component, OnInit,Input } from '@angular/core';
// import { Driver } from '../driver';
// import { Carrier } from '../../carrier/carrier';
import { Passenger } from '../passenger';

import { ActivatedRoute, Params } from '@angular/router';
import { PassengerService } from '../passenger.service';
// import { CarrierService } from '../../carrier/carrier.service';

@Component({
    selector: 'passenger-detail',
    templateUrl: './passenger-detail.component.html',
    //  styleUrls: ['./driver-detail.component.css']
})

export class PassengerDetailComponent implements OnInit {
    @Input()
    passenger: Passenger;

    // carriers: Carrier[];

    constructor(
        
        private passengerService: PassengerService,
        private router: ActivatedRoute) {

    }

    ngOnInit() {
        this.router.params.forEach((params: Params) => {
            let passenger_id = params['passenger_id'];
            this.passengerService.getPassenger(passenger_id).then(passenger => this.passenger = passenger);

            // this.carrierService.getCarriers().then(carrier => this.carriers = carrier);
        });
    }

    goBack() {
        window.history.back();
    }

    save(): void {
        this.passengerService.save(this.passenger).then(() => this.cancel());
    }

    // delete(): void {
    //     this.passengerService.delete(this.passenger).then(() => this.cancel());
    // }

    cancel(): void {
        this.passenger = null;
    }
}